Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep track of crates that are whitelisted to be used even if yanked #6611

Merged
merged 9 commits into from
Feb 4, 2019

Conversation

Eh2406
Copy link
Contributor

@Eh2406 Eh2406 commented Jan 28, 2019

This is a start on #6609. It definitely needs tests that the bug is fixed, and to reduce the clones. But for now let's see what CI thinks.

src/cargo/ops/cargo_install.rs Outdated Show resolved Hide resolved
pub fn load<'a>(
self,
config: &'a Config,
yanked_whitelist: HashSet<PackageId>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might help clean things up to plumb through &HashSet<PackageId> mostly and then only clone when necessary at the bottom

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been experimenting but plumbing thure the lifetime can be annoying. I will try again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and to be clear I wouldn't connect the lifetime to anything, only passing around a borrow and then when it needs to be stored cloning it

src/cargo/core/registry.rs Outdated Show resolved Hide resolved
src/cargo/sources/registry/index.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Jan 29, 2019

☔ The latest upstream changes (presumably #6591) made this pull request unmergeable. Please resolve the merge conflicts.

@Eh2406 Eh2406 force-pushed the conservative-updates branch 2 times, most recently from 7ea62a1 to 3608368 Compare January 29, 2019 21:59
@Eh2406
Copy link
Contributor Author

Eh2406 commented Jan 29, 2019

I think I have addressed your suggestions. Next time I look at this it will be time to add a test, suggestions welcome.

@Eh2406
Copy link
Contributor Author

Eh2406 commented Jan 30, 2019

Ok that is 2 tests and it seems to not be working. :-(
I don't know why not. @alexcrichton suggestions?

@alexcrichton
Copy link
Member

Oh so I bet this is related to replaced sources. In src/cargo/sources/config.rs I think that you'll need to apply the config mappings to the whitelisted ids?

@alexcrichton
Copy link
Member

(the "related to" being that the package ids aren't equal I think because the source ids change as they flow through the config source)

@Eh2406
Copy link
Contributor Author

Eh2406 commented Jan 30, 2019

Still not passing. Is it something silly? I am worried that it has to do with poisoning all of a registry leading to us whitelisting to little.

@alexcrichton
Copy link
Member

Hm without digging in too much just yet, it may be that the replacement happens the other way around or something like that? Or maybe something needs to be swapped?

It may be worthwhile to add some debugging prints and such to see if the failing tests can be diagnosed more directly too

@Eh2406
Copy link
Contributor Author

Eh2406 commented Jan 31, 2019

cargo\sources\registry\index.rs

    pub fn query_inner(
...

+        if !yanked_whitelist.is_empty() {
+            println!("dep.name: {:?} dep.source_id(): {:?}", name, dep.source_id().to_string());
+            println!("yanked_whitelist: {:?}", yanked_whitelist);
+        }

then running yanks_in_lockfiles_are_ok_with_new_dep

dep.name: "bar" dep.source_id(): "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`"
yanked_whitelist: {PackageId { name: "foo", version: "0.0.1", source: "C:\\...\\cargo\\target\\cit\\t0\\foo" }}
dep.name: "baz" dep.source_id(): "registry `C:\\....\\cargo\\target\\cit\\t0\\registry`"
yanked_whitelist: {PackageId { name: "foo", version: "0.0.1", source: "C:\\...\\cargo\\target\\cit\\t0\\foo" }}
dep.name: "bar" dep.source_id(): "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`"
yanked_whitelist: {PackageId { name: "foo", version: "0.0.1", source: "C:\\...\\cargo\\target\\cit\\t0\\foo" }}
dep.name: "bar" dep.source_id(): "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`"
yanked_whitelist: {PackageId { name: "foo", version: "0.0.1", source: "C:\\...\\cargo\\target\\cit\\t0\\foo" }}

So "bar" is not making it to the yanked_whitelist

yanks_in_lockfiles_are_ok_for_other_update

running `C:\Users\...\cargo\target\debug\cargo.exe build`
running `C:\Users\...\cargo\target\debug\cargo.exe build`
dep.name: "bar" dep.source_id(): "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`"
yanked_whitelist: {PackageId { name: "baz", version: "0.0.1", source: "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`" }, PackageId { name: "bar", version: "0.0.1", source: "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`" }, PackageId { name: "foo", version: "0.0.1", source: "C:\\...\\cargo\\target\\cit\\t0\\foo" }}
dep.name: "baz" dep.source_id(): "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`"
yanked_whitelist: {PackageId { name: "baz", version: "0.0.1", source: "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`" }, PackageId { name: "bar", version: "0.0.1", source: "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`" }, PackageId { name: "foo", version: "0.0.1", source: "C:\\...\\cargo\\target\\cit\\t0\\foo" }}
dep.name: "bar" dep.source_id(): "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`"
yanked_whitelist: {PackageId { name: "baz", version: "0.0.1", source: "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`" }, PackageId { name: "bar", version: "0.0.1", source: "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`" }, PackageId { name: "foo", version: "0.0.1", source: "C:\\...\\cargo\\target\\cit\\t0\\foo" }}
dep.name: "baz" dep.source_id(): "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`"
yanked_whitelist: {PackageId { name: "baz", version: "0.0.1", source: "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`" }, PackageId { name: "bar", version: "0.0.1", source: "registry `C:\\...\\cargo\\target\\cit\\t0\\registry`" }, PackageId { name: "foo", version: "0.0.1", source: "C:\\...\\cargo\\target\\cit\\t0\\foo" }}

So I think we are mapping the source correctly

@alexcrichton
Copy link
Member

Oh right, turns out this location is too aggressive and is the wrong place for this check.

Let's go back to an explicit method to add an entry to the whitelist, and then regardless of update flags add the entire previous lockfile to the whitelist.

@Eh2406
Copy link
Contributor Author

Eh2406 commented Jan 31, 2019

Ok reverted the relevant commit. I think entire previous lockfile may be two brod. cargo update no longer errores, there is a resolution the old lockfile.

@Eh2406
Copy link
Contributor Author

Eh2406 commented Jan 31, 2019

Given the number of people who are dealing with broken builds, feel free to push to this PR if that is faster than explaining an idea.

If we're updating a crate then its previous version in the lock file is
no longer whitelisted. We may want to perhaps change this in the future!
@alexcrichton
Copy link
Member

Ok I've pushed up a few commits I found locally, but they don't fix the issue. I have, however, found the issue! The problem is that we're loading a registry when the whitelist is empty, and then afterwards we're adding to the whitelist. The update of the whitelist in the second step isn't getting propagated to the registry source because the registry source is always loaded.

The offending add is here:

registry.add_sources(sources)?;

I'm open to possible solutions. I think we'll want some sort of assertion one way or another to ensure this doesn't happen (e.g. if the whitelist is updated the are no loaded sources), but that's somewhat difficult as we add sources in a few places. Otherwise we could try just taking the whitelist a lot sooner, but that may make taking the whitelist a bit larger.

Other solutions could involve passing the whitelist through the query method perhaps

@Eh2406
Copy link
Contributor Author

Eh2406 commented Feb 2, 2019

I don't think I understand the levels of abstractions well enough to have anything intelligent to say on how this "should" be solved. If you have a more concrete set of steps I can try to follow them.

When sources already exist in a `PackageRegistry` and the whitelist is
updated in the package registry, be sure to update all the existing
sources to ensure that everyone gets the same view of the intended whitelist.
@alexcrichton
Copy link
Member

Ok I've pushed a commit which I believe fixes the tests and makes this pass everything now, want to take a look @Eh2406?

@Eh2406
Copy link
Contributor Author

Eh2406 commented Feb 3, 2019

That is a clever solution. LGTM, for all I understand it.

@alexcrichton alexcrichton changed the title [WIP] keep track of crates that are whitelisted to be used even if yanked keep track of crates that are whitelisted to be used even if yanked Feb 4, 2019
@alexcrichton
Copy link
Member

@bors: r+

Alright, let's merge this then!

@bors
Copy link
Contributor

bors commented Feb 4, 2019

📌 Commit 4a2f810 has been approved by alexcrichton

bors added a commit that referenced this pull request Feb 4, 2019
keep track of crates that are whitelisted to be used even if yanked

This is a start on #6609. It definitely needs tests that the bug is fixed, and to reduce the clones. But for now let's see what CI thinks.
@bors
Copy link
Contributor

bors commented Feb 4, 2019

⌛ Testing commit 4a2f810 with merge 37ad03f...

@bors
Copy link
Contributor

bors commented Feb 4, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: alexcrichton
Pushing 37ad03f to master...

@bors bors merged commit 4a2f810 into rust-lang:master Feb 4, 2019
@Eh2406 Eh2406 deleted the conservative-updates branch February 9, 2019 03:34
bors added a commit to rust-lang/rust that referenced this pull request Feb 10, 2019
Bump cargo to 865cb70

Merged PRs:

* Replace util::without_prefix with Path::strip_prefix rust-lang/cargo#6620
* keep track of crates that are whitelisted to be used even if yanked rust-lang/cargo#6611
* Fix default DYLD_FALLBACK_LIBRARY_PATH on MacOS. rust-lang/cargo#6625
* Bail when trying to run "test --doc --no-run" rust-lang/cargo#6628
* In cargo test's help, add that examples are built rust-lang/cargo#6619
* Extract & re-use filter_targets in cargo_compile rust-lang/cargo#6621
* Test cleanup: remove unnecessary with_status(0) rust-lang/cargo#6630
* Fix run's help message rust-lang/cargo#6631
* Some updates to bash completion. rust-lang/cargo#6644
* Introduce Source::download_now rust-lang/cargo#6637
* Switch from unused_imports to deprecated to test unfixable warnings rust-lang/cargo#6649
bors added a commit to rust-lang/rust that referenced this pull request Feb 11, 2019
Bump cargo to 865cb70

Merged PRs:

* Replace util::without_prefix with Path::strip_prefix rust-lang/cargo#6620
* keep track of crates that are whitelisted to be used even if yanked rust-lang/cargo#6611
* Fix default DYLD_FALLBACK_LIBRARY_PATH on MacOS. rust-lang/cargo#6625
* Bail when trying to run "test --doc --no-run" rust-lang/cargo#6628
* In cargo test's help, add that examples are built rust-lang/cargo#6619
* Extract & re-use filter_targets in cargo_compile rust-lang/cargo#6621
* Test cleanup: remove unnecessary with_status(0) rust-lang/cargo#6630
* Fix run's help message rust-lang/cargo#6631
* Some updates to bash completion. rust-lang/cargo#6644
* Introduce Source::download_now rust-lang/cargo#6637
* Switch from unused_imports to deprecated to test unfixable warnings rust-lang/cargo#6649
bors added a commit that referenced this pull request Feb 12, 2019
[BackPort] Conservative updates

This is a back port of #6611 as discussed in #6609
@ehuss ehuss modified the milestones: 1.34.0, 1.33.0 Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants